from random import randint
class Solution:
    def finalPositionOfSnake(self, n: int, commands: list[str]) -> int:
        col, line = 0, 0
        for i in commands:
            if i == "UP":
                line -= 1
            elif i == "RIGHT":
                col += 1
            elif i == "DOWN":
                line += 1
            elif i == "LEFT":
                col -= 1

        return line * n + col

if __name__ == '__main__':
    s = Solution()
    commands = list()
    for i in range(10):
        c = ["DOWN","UP","LEFT","RIGHT"]
        commands.append(c[randint(0,3)])
    print(commands)
    print(s.finalPositionOfSnake(10, commands))
